package mao.exaimnation.meituan;

import java.util.Scanner;

/**
 * @author Totoro
 * @date 2020/8/29
 * @explain: 字符串加密解密，加密使用M.*T作前缀，M.*T 作为后缀。
 *           解码过程尽量保证，解码出来的字符串尽量长。
 */
public class Main1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            int n = scanner.nextInt();
            String next = scanner.next();
            int start = 0;
            int end = 0;
            boolean M = false;
            boolean T = false;
            for (int i = 0; i < next.length(); i++) {
                if (next.charAt(i) == 'M'){
                    M = true;
                }else if (next.charAt(i) == 'T'  && M){
                    start = i;
                    break;
                }
            }
            M = false;
            T  = false;
            for (int i = next.length()-1; i >= 0; i--) {
                if (next.charAt(i) == 'T'){
                    T = true;
                }else if (next.charAt(i) == 'M' && T==true){
                    end = i;
                    break;
                }
            }
            System.out.println(next.substring(start+1,end));
        }
    }
}
